/*
	循环显示的“HELLO”　　
	设计一个电路实现在HEX7～HEX0上循环显示“HELLO”，
	使所有字母从右向左移动，每秒移动一次，
*/
module seg_led_r_l(
	input wire clk,
	input wire rst_n,
	input wire sec_1,
	output reg [55:0] hex
);

//控制数码管位选信号(注:低电平有效),选中所有的数码管
always@(posedge clk or negedge rst_n)begin
	if(!rst_n)begin
		hex<=56'b1111111_1111111_1111111_0001001_0000110_1000111_1000111_1000000;
	end
	else begin
		if(sec_1)
		 hex<={hex[48:0],hex[55:49]};
		 else 
		 hex<=hex;
	end
end
endmodule

module time_count(
	input wire clk,//时钟，50MHZ
	input wire rst_n,//复位信号，下降沿有效
	output reg sec_1//1s脉冲信号
);
parameter MAX_NUM=26'd49_999_999;//记最大数,时间1s
reg [25:0] cnt;//计数寄存器
//1s计时
always@(posedge clk or negedge rst_n)begin
	if(!rst_n)begin
		cnt<=26'd0;
	end
	else if(cnt<MAX_NUM)begin
		cnt<=cnt+1'd1;
	end
	else
	   cnt<=26'd0;
end
//1s脉冲信号
always@(posedge clk or negedge rst_n)begin
	if(!rst_n)begin
		sec_1<=1'b0;
	end
	else if(cnt==MAX_NUM)begin
		sec_1<=1'b1;
	end
	else begin
		sec_1<=1'b0;
	end
end
endmodule

module Cdisplay_5(
	input wire clk,
	input wire rst_n,
	input wire [1:0] key,
	output	wire	[55:0]	hex
);

wire sec_1;
wire [1:0] flag;
wire [1:0] key_value;
//每隔1s产生一个时钟周期的脉冲信号
time_count inst_time_count(
	.clk		(clk)  ,  //50MHz时钟信号
	.rst_n	(rst_n),  //复位信号
	.sec_1	(sec_1)//一个时钟周期的脉冲信号
);

seg_led_r_l inst_seg_led_r_l(
.clk      (clk  ),
.rst_n    (rst_n),
.sec_1	(sec_1),
     
.hex      (hex  )

);

endmodule




/*
module Cdisplay_5(clk50m,rest,HEX7,HEX6,HEX5,HEX4,HEX3,HEX2,HEX1,HEX0);
	input clk50m,rest;
	output reg[0:6] HEX7,HEX6,HEX5,HEX4,HEX3,HEX2,HEX1,HEX0;
	reg [25:0] cnt;
	reg [3:0] clk2;
	reg clk1;

	always @(posedge clk50m or negedge rest)
		begin
			if(!rest)
				begin  cnt<=0;end
			else if(cnt==26'd50000000)
				begin cnt<=0;clk1<=~clk1;end
			else cnt<=cnt+1;
		end

	always @(posedge clk1 or negedge rest)begin
		if(!rest)
			begin  clk2<=4'd0;end
		else
			if(clk2==4'b1001)
				begin clk2<=4'd0;end
			else
				clk2<=clk2+16'b0000000000000001;
	end
	
	always @(*) begin
		case(clk2)
			4'b0000:begin HEX4=~7'b0110111;HEX3=~7'b1001111;HEX2=~7'b0001110;HEX1=~7'b0001110;HEX0=~7'b1111110;end
			4'b0001:begin HEX5=~7'b0110111;HEX4=~7'b1001111;HEX3=~7'b0001110;HEX2=~7'b0001110;HEX1=~7'b1111110;end
			4'b0010:begin HEX6=~7'b0110111;HEX5=~7'b1001111;HEX4=~7'b0001110;HEX3=~7'b0001110;HEX2=~7'b1111110;end
			4'b0011:begin HEX7=~7'b0110111;HEX6=~7'b1001111;HEX5=~7'b0001110;HEX4=~7'b0001110;HEX3=~7'b1111110;end
			4'b0100:begin HEX0=~7'b0110111;HEX7=~7'b1001111;HEX6=~7'b0001110;HEX5=~7'b0001110;HEX4=~7'b1111110;end
			4'b0101:begin HEX1=~7'b0110111;HEX0=~7'b1001111;HEX7=~7'b0001110;HEX6=~7'b0001110;HEX5=~7'b1111110;end
			4'b0111:begin HEX2=~7'b0110111;HEX1=~7'b1001111;HEX0=~7'b0001110;HEX7=~7'b0001110;HEX6=~7'b1111110;end
			4'b1000:begin HEX3=~7'b0110111;HEX2=~7'b1001111;HEX1=~7'b0001110;HEX0=~7'b0001110;HEX7=~7'b1111110;end
			default:begin HEX0=~7'b0000000;HEX1=~7'b0000000;HEX2=~7'b0000000;HEX3=~7'b0000000;HEX4=~7'b0000000;
				HEX5=~7'b0000000;HEX6=~7'b0000000;HEX7=~7'b0000000;end
		endcase
	end
endmodule

*/